package com.maket.jbxx.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.maket.jbxx.domain.SxAttributeValue;
import com.maket.jbxx.service.ISxAttributeValueService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 属性值Controller
 * 
 * @author ruoyi
 * @date 2024-07-02
 */
@RestController
@RequestMapping("/value")
public class SxAttributeValueController extends BaseController
{
    @Autowired
    private ISxAttributeValueService sxAttributeValueService;

    /**
     * 查询属性值列表
     */
    @RequiresPermissions("jbxx:value:list")
    @GetMapping("/list")
    public TableDataInfo list(SxAttributeValue sxAttributeValue)
    {
        startPage();
        List<SxAttributeValue> list = sxAttributeValueService.selectSxAttributeValueList(sxAttributeValue);
        return getDataTable(list);
    }

    /**
     * 导出属性值列表
     */
    @RequiresPermissions("jbxx:value:export")
    @Log(title = "属性值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SxAttributeValue sxAttributeValue)
    {
        List<SxAttributeValue> list = sxAttributeValueService.selectSxAttributeValueList(sxAttributeValue);
        ExcelUtil<SxAttributeValue> util = new ExcelUtil<SxAttributeValue>(SxAttributeValue.class);
        util.exportExcel(response, list, "属性值数据");
    }

    /**
     * 获取属性值详细信息
     */
    @RequiresPermissions("jbxx:value:query")
    @GetMapping(value = "/{zId}")
    public AjaxResult getInfo(@PathVariable("zId") Long zId)
    {
        return success(sxAttributeValueService.selectSxAttributeValueByZId(zId));
    }

    /**
     * 新增属性值
     */
    @RequiresPermissions("jbxx:value:add")
    @Log(title = "属性值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SxAttributeValue sxAttributeValue)
    {
        return toAjax(sxAttributeValueService.insertSxAttributeValue(sxAttributeValue));
    }

    /**
     * 批量新增属性值
     */
    @RequiresPermissions("jbxx:value:add")
    @Log(title = "属性值", businessType = BusinessType.INSERT)
    @PostMapping("batchInsertSxAttributeValue")
    public AjaxResult addBatchInsertSxAttributeValue(@RequestBody List<SxAttributeValue> sxAttributeValue)
    {
        return toAjax(sxAttributeValueService.batchInsertSxAttributeValue(sxAttributeValue));
    }

    /**
     * 修改属性值
     */
    @RequiresPermissions("jbxx:value:edit")
    @Log(title = "属性值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SxAttributeValue sxAttributeValue)
    {
        return toAjax(sxAttributeValueService.updateSxAttributeValue(sxAttributeValue));
    }

    /**
     * 删除属性值
     */
    @RequiresPermissions("jbxx:value:remove")
    @Log(title = "属性值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zIds}")
    public AjaxResult remove(@PathVariable Long[] zIds)
    {
        return toAjax(sxAttributeValueService.deleteSxAttributeValueByZIds(zIds));
    }
}
